/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "MODULO_CURSO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ModuloCurso.findAll", query = "SELECT m FROM ModuloCurso m"),
    @NamedQuery(name = "ModuloCurso.findByCurbCod", query = "SELECT m FROM ModuloCurso m WHERE m.moduloCursoPK.curbCod = :curbCod"),
    @NamedQuery(name = "ModuloCurso.findByModCod", query = "SELECT m FROM ModuloCurso m WHERE m.moduloCursoPK.modCod = :modCod"),
    @NamedQuery(name = "ModuloCurso.findByModcNhor", query = "SELECT m FROM ModuloCurso m WHERE m.modcNhor = :modcNhor"),
    @NamedQuery(name = "ModuloCurso.findByModcOrd", query = "SELECT m FROM ModuloCurso m WHERE m.modcOrd = :modcOrd")})
public class ModuloCurso implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ModuloCursoPK moduloCursoPK;
    @Basic(optional = false)
    @Column(name = "MODC_NHOR")
    private int modcNhor;
    @Column(name = "MODC_ORD")
    private Integer modcOrd;
    @JoinColumn(name = "MOD_COD", referencedColumnName = "MOD_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Modulo modulo;
    @JoinColumn(name = "CURB_COD", referencedColumnName = "CURB_COD", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private CursoBase cursoBase;
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public ModuloCurso() {
    }

    public ModuloCurso(ModuloCursoPK moduloCursoPK) {
        this.moduloCursoPK = moduloCursoPK;
    }

    public ModuloCurso(ModuloCursoPK moduloCursoPK, int modcNhor) {
        this.moduloCursoPK = moduloCursoPK;
        this.modcNhor = modcNhor;
    }

    public ModuloCurso(int curbCod, int modCod) {
        this.moduloCursoPK = new ModuloCursoPK(curbCod, modCod);
    }

    public ModuloCursoPK getModuloCursoPK() {
        return moduloCursoPK;
    }

    public void setModuloCursoPK(ModuloCursoPK moduloCursoPK) {
        ModuloCursoPK old = this.moduloCursoPK;
        this.moduloCursoPK = moduloCursoPK;
        changeSupport.firePropertyChange("moduloCursoPK", old, moduloCursoPK);
    }

    public int getModcNhor() {
        return modcNhor;
    }

    public void setModcNhor(int modcNhor) {
        int old = this.modcNhor;
        this.modcNhor = modcNhor;
        changeSupport.firePropertyChange("modcNhor", old, modcNhor);
    }

    public Integer getModcOrd() {
        return modcOrd;
    }

    public void setModcOrd(Integer modcOrd) {
        Integer old = this.modcOrd;
        this.modcOrd = modcOrd;
        changeSupport.firePropertyChange("modcOrd", old, modcOrd);
    }

    public Modulo getModulo() {
        return modulo;
    }

    public void setModulo(Modulo modulo) {
        Modulo old = this.modulo;
        this.modulo = modulo;
        changeSupport.firePropertyChange("modulo", old, modulo);
    }

    public CursoBase getCursoBase() {
        return cursoBase;
    }

    public void setCursoBase(CursoBase cursoBase) {
        CursoBase old = this.cursoBase;
        this.cursoBase = cursoBase;
        changeSupport.firePropertyChange("cursoBase", old, cursoBase);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (moduloCursoPK != null ? moduloCursoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ModuloCurso)) {
            return false;
        }
        ModuloCurso other = (ModuloCurso) object;
        if ((this.moduloCursoPK == null && other.moduloCursoPK != null) || (this.moduloCursoPK != null && !this.moduloCursoPK.equals(other.moduloCursoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.ModuloCurso[ moduloCursoPK=" + moduloCursoPK + " ]";
    }
    
    public void addPropertyChangeListener(PropertyChangeListener l){
        changeSupport.addPropertyChangeListener(l);
    }
    
    public void removePropertyChangeListener(PropertyChangeListener l){
        changeSupport.removePropertyChangeListener(l);
    }
}
